package com.aiju.widgit;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.TextView;

import com.aiju.base.R;
import com.aiju.common.PixValue;

/**
 * @author: 佐为
 * @date: 2016-11-16 15:01
 * @version: V1.0
 * @Description: 选中状态左侧出现蓝色长条
 */
public class LeftBarTextView extends TextView {

    private Rect tempRect = new Rect();
    private Paint borderPaint;
    private int mBorderColor = getResources().getColor(R.color.app_display_color);
    private int mBoderLeftSize = PixValue.dp.valueOf(3);

    public LeftBarTextView(Context context) {
        super(context);
        init();
    }

    public LeftBarTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        borderPaint = new Paint();
        borderPaint.setColor(mBorderColor);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int vw = getWidth();
        int vh = getHeight();

        if (isSelected()) {
            tempRect.setEmpty();
            tempRect.set(0, 0, mBoderLeftSize, vh);
            canvas.drawRect(tempRect, borderPaint);
        }
    }

}
